﻿using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace QLDV.Infrastructure.IoC
{
    public class UnityControllerFactory : DefaultControllerFactory
    {
        public override IController CreateController(RequestContext requestContext,
                                                     string controllerName)
        {
            var provider = HttpContext.Current.ApplicationInstance as IContainerProvider;
            if (provider == null)
                throw new InvalidOperationException("Application class must implement IContainerProvider");

            if (controllerName == "favicon.ico" | controllerName == "index.html"| controllerName =="jorgchart"
                | controllerName == "Content")
                return null;
            return provider.Container.Resolve<IController>(controllerName);
        }
    }
}